package net.yeah.mickey_zhouyou.database.util.new_instance_policy;

import java.lang.reflect.Constructor;

import net.yeah.mickey_zhouyou.database.sequence.Sequence;
import net.yeah.mickey_zhouyou.database.util.NewInstancePolicy;

public class NewSequencePolicy implements NewInstancePolicy<Sequence> {

	@Override
	public Sequence newInstance(String className) {
		try {
			Constructor<?> constructor = Class.forName(className)
					.getDeclaredConstructor(String.class);
			constructor.setAccessible(true);
			return (Sequence) constructor.newInstance("");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	private NewSequencePolicy() {
	}

	private static final NewSequencePolicy policy = new NewSequencePolicy();

	public static NewSequencePolicy getPolicy() {
		return policy;
	}

}
